<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles"
	prefix="tiles"%>
<f:verbatim>
<script>
	function setValue(t){
		document.getElementById("pform:test").value = t;
	}
</script>
</f:verbatim>
<h:inputHidden validator="#{adminCommSchBean.validator}" value="#{adminCommSchBean.test}" id="test"></h:inputHidden>
<rich:panel header="#{messages['edit.commission.schema']}">
	<h:panelGrid>
		<h:outputText value="#{errorBean.errorMessage}" styleClass="error"></h:outputText>
	</h:panelGrid>

	<t:panelGrid columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<h:outputText></h:outputText>
		<t:message for="code" styleClass="error"></t:message>
	
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="code" value="#{messages['code']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:inputText id="code" required="#{adminCommSchBean.check}" size="50" maxlength="50" styleClass="standardText" value="#{adminCommSchBean.schema.code}"></t:inputText>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="name" styleClass="error"></t:message>
		
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="name" value="#{messages['name']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:inputText id="name" required="#{adminCommSchBean.check}" size="50" maxlength="50" styleClass="standardText" value="#{adminCommSchBean.schema.name}"></t:inputText>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="desc" styleClass="error"></t:message>
		
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="desc" value="#{messages['desc']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:inputTextarea id="desc" cols="20" rows="5" value="#{adminCommSchBean.schema.desc}"></t:inputTextarea>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="commissiontype" styleClass="error"></t:message>
		
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="commissiontype" value="#{messages['accumulate.type']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:selectOneRadio id="commissiontype" styleClass="standardText" value="#{adminCommSchBean.schema.accumulateType}" required="#{adminCommSchBean.check}">
				<f:selectItems value="#{adminCommSchBean.accumulateType}"/>
			</t:selectOneRadio>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="type" styleClass="error"></t:message>
		
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="type" value="#{messages['commission.type']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:selectOneRadio id="type" styleClass="standardText" value="#{adminCommSchBean.catType}" required="#{adminCommSchBean.check}">
				<f:selectItems value="#{adminCommSchBean.commissionType}"/>
				<a4j:support ajaxSingle="true" reRender="cat,range" event="onclick"></a4j:support>
			</t:selectOneRadio>
		</h:panelGroup>
	</t:panelGrid>
	
	<t:panelGrid id="cat" columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<h:outputText rendered="#{adminCommSchBean.flag}"></h:outputText>
		<t:message for="membershipcategory" styleClass="error" rendered="#{adminCommSchBean.flag}"></t:message>
		
		<h:panelGroup rendered="#{adminCommSchBean.flag}">
			<h:outputText value="*" styleClass="standardText_Mandatory" rendered="#{adminCommSchBean.flag}"/>
			<h:outputLabel for="membershipcategory" value="#{messages['membership']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup rendered="#{adminCommSchBean.flag}">
			<rich:dataTable id="membershipcategory" value="#{adminCommSchBean.commMembershipList}" var="cmembership" width="100%">
				<rich:column style="text-align:center;width:40%;" >
					<f:facet name="header">
						<h:outputText  value="#{messages['name']}" styleClass="standardText_Label" />
					</f:facet>
					<h:outputText value="#{cmembership.membership.name}"></h:outputText>
				</rich:column>
				<rich:column style="text-align:center;width:30%;" >
					<f:facet name="header">
						<h:outputText  value="#{messages['value.type']}" styleClass="standardText_Label" />
					</f:facet>
					<t:selectOneRadio id="valuetype" styleClass="standardText" value="#{cmembership.type}">
						<f:selectItems value="#{adminCommSchBean.valueType}"/>
					</t:selectOneRadio>
				</rich:column>
				<rich:column style="text-align:center;width:30%;" >
					<f:facet name="header">
						<h:outputText  value="#{messages['value']}" styleClass="standardText_Label" />
					</f:facet>
					<t:inputText size="50" maxlength="50" styleClass="standardText" value="#{cmembership.valueDbl}">
						<f:convertNumber pattern="##0.0"/>
					</t:inputText>
				</rich:column>
			</rich:dataTable>
		</h:panelGroup>
	</t:panelGrid>
	
	<%--<t:panelGrid id="cat" columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<h:outputText rendered="#{adminCommSchBean.flag}"></h:outputText>
		<t:message for="membershipcategory" styleClass="error" rendered="#{adminCommSchBean.flag}"></t:message>
		
		<h:panelGroup rendered="#{adminCommSchBean.flag}">
			<h:outputText value="*" styleClass="standardText_Mandatory" rendered="#{adminCommSchBean.flag}"/>
			<h:outputLabel for="membershipcategory" value="#{messages['membership']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup rendered="#{adminCommSchBean.flag}">
			<t:selectOneMenu id="membershipcategory" styleClass="standardText" value="#{adminCommSchBean.membershipId}" required="#{adminCommSchBean.check}">
				<f:selectItem itemLabel="#{messages['please.select']}" itemValue="" />
				<f:selectItems value="#{adminCommSchBean.membershipList}"/>
			</t:selectOneMenu>
		</h:panelGroup>
		
		<h:outputText rendered="#{adminCommSchBean.flag}"></h:outputText>
		<t:message for="valuetype" styleClass="error" rendered="#{adminCommSchBean.flag}"></t:message>
		
		<h:panelGroup rendered="#{adminCommSchBean.flag}">
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="valuetype" value="#{messages['value.type']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup rendered="#{adminCommSchBean.flag}">
			<t:selectOneRadio id="valuetype" styleClass="standardText" value="#{adminCommSchBean.schema.valueType}" required="#{adminCommSchBean.check}">
				<f:selectItems value="#{adminCommSchBean.valueType}"/>
			</t:selectOneRadio>
		</h:panelGroup>
		
		<h:outputText rendered="#{adminCommSchBean.flag}"></h:outputText>
		<t:message for="value" styleClass="error" rendered="#{adminCommSchBean.flag}"></t:message>
		
		<h:panelGroup rendered="#{adminCommSchBean.flag}">
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="value" value="#{messages['value']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup rendered="#{adminCommSchBean.flag}">
			<t:inputText id="value" required="#{adminCommSchBean.check}" size="50" maxlength="50" styleClass="standardText" value="#{adminCommSchBean.schema.valueDbl}">
				<f:convertNumber pattern="##0.0"/>
				<f:validateLength maximum="100" minimum="0"/>
			</t:inputText>
			<f:verbatim>&nbsp;</f:verbatim>
			<h:outputText styleClass="standardText_Label" value="#{messages['percent']}"></h:outputText>
		</h:panelGroup>
	</t:panelGrid>--%>
	
	<t:panelGrid id="range" columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
	
		<h:panelGroup rendered="#{!adminCommSchBean.flag}">
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputText value="#{messages['payment.range']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup rendered="#{!adminCommSchBean.flag}">
		<rich:dataTable id="data" var="schema" value="#{adminCommSchBean.rangeList}" rows="20" width="99%" >
			<rich:column style="text-align:center;width:20%;" >
				<f:facet name="header">
					<h:outputText  value="#{messages['from']}" styleClass="standardText_Label" />
				</f:facet>
				<t:inputText readonly="true" size="10" maxlength="10" styleClass="standardText" value="#{schema.fromDbl}"></t:inputText>
			</rich:column>
			<rich:column style="text-align:center;width:20%;" >
				<f:facet name="header">
					<h:outputText  value="#{messages['to']}" styleClass="standardText_Label" />
				</f:facet>
				<t:panelGroup>
					<t:inputText size="10" maxlength="10" styleClass="standardText" value="#{schema.toDbl}" readonly="#{!schema.flag}">
						<f:convertNumber pattern="##0.0"/>
					</t:inputText>
				</t:panelGroup>
			</rich:column>
			<rich:column style="text-align:center;width:20%;" >
				<f:facet name="header">
					<h:outputText  value="#{messages['percent']}" styleClass="standardText_Label" />
				</f:facet>
				<t:panelGroup>
					<t:inputText size="10" maxlength="10" styleClass="standardText" value="#{schema.percentDbl}">
						<f:convertNumber pattern="##0.0"/>
						<f:validateLength maximum="100" minimum="0"/>
					</t:inputText>
					<f:verbatim>&nbsp;</f:verbatim>
					<h:outputText styleClass="standardText_Label" value="#{messages['percent']}"></h:outputText>
				</t:panelGroup>
			</rich:column>
			<rich:column style="text-align:center;width:20%;" >
				<f:facet name="header">
					<h:outputText  value="#{messages['action']}" styleClass="standardText_Label" />
				</f:facet>
				<h:commandLink value="#{messages['remove']}" styleClass="standardText" rendered="#{schema.flag}" 
				action="#{adminCommSchBean.removeAction}" onclick="setValue(1)"></h:commandLink>
				<h:outputText rendered="#{!schema.flag}"></h:outputText>
			</rich:column>
		</rich:dataTable>
		<h:commandLink value="#{messages['add.more']}" styleClass="standardText" 
		action="#{adminCommSchBean.addMoreUpdateAction}" onclick="setValue(1)"></h:commandLink>
		
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="effectivedate" styleClass="error"></t:message>
	
	    <h:panelGroup>
	    	<h:outputText value="*" styleClass="standardText_Mandatory" />	
		    <h:outputLabel for="effectivedate" value="#{messages['effective.date']}" styleClass="standardText_Label" />
	    </h:panelGroup>
	    <h:panelGroup>
	    	<t:inputCalendar
	    	id="effectivedate"
				monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader" 
				currentDayCellClass="currentDayCell" value="#{adminCommSchBean.schema.effectiveDate}"
				renderAsPopup="true" popupTodayString="#{messages['popup.today']}"
				popupWeekString="#{messages['popup.week']}" popupDateFormat="dd/MM/yyyy"
				renderPopupButtonAsImage="true"
				styleClass="standardText" required="#{adminCommSchBean.check}">
	    	</t:inputCalendar>
	    </h:panelGroup>
	    
	    <h:outputText></h:outputText>
		<t:message for="expirydate" styleClass="error"></t:message>
	
	    <h:panelGroup>
	    	<h:outputText value="*" styleClass="standardText_Mandatory" />	
		    <h:outputLabel for="expirydate" value="#{messages['expiry.date']}" styleClass="standardText_Label" />
	    </h:panelGroup>
	    <h:panelGroup>
	    	<t:inputCalendar
	    	id="expirydate"
				monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader" 
				currentDayCellClass="currentDayCell" value="#{adminCommSchBean.schema.expiryDate}"
				renderAsPopup="true" popupTodayString="#{messages['popup.today']}"
				popupWeekString="#{messages['popup.week']}" popupDateFormat="dd/MM/yyyy"
				renderPopupButtonAsImage="true"
				styleClass="standardText" required="#{adminCommSchBean.check}">
	    	</t:inputCalendar>
	    </h:panelGroup>
		
	</t:panelGrid>
	
	<rich:spacer height="30"></rich:spacer>
	
	<t:panelGrid columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<h:outputText></h:outputText>
		<t:panelGrid columns="2">
			<h:commandButton value="#{messages['update']}" styleClass="button" action="#{adminCommSchBean.editAction}" onclick="document.getElementById('pform:test').value = 0"></h:commandButton>
			<h:commandButton value="#{messages['cancel']}" styleClass="button" action="#{adminCommSchBean.navListAction}" immediate="true"></h:commandButton>
		</t:panelGrid>
	</t:panelGrid>
	
</rich:panel>